#include <iostream>
using namespace std;
// #define MaxSize 50
#define MaxSize 10

typedef struct intSigleQueue
{
    int data[MaxSize];
    int front = -1;
    int rear = -1;
} ISQ;

bool enqueue(ISQ *queue, int n)
{
    if ((queue->rear + queue->front)%MaxSize == MaxSize - 2){
        puts("stack over");
        return false;
    }

    queue->data[++queue->front%MaxSize] = n;
    return true;
}

int outqueue(ISQ *queue)
{
    if (queue->rear == queue->front)
        return -1;
    return queue->data[++queue->rear%MaxSize];
}

int rear(ISQ *queue)
{
    if (queue->rear == queue->front)
        return -1;
    return queue->data[queue->rear+1%MaxSize];
}
ISQ *init()
{
    ISQ *queue = new ISQ();
    for (int i = 0; i < 10; i++)
    {
        enqueue(queue,i+1);
    }
    for (int i = 0; i < 5; i++)
    {
        outqueue(queue);
    }
    for (int i = 0; i < 7; i++)
    {
        enqueue(queue,i+50);
    }
    return queue;
}
int main(int argc, char const *argv[])
{
    ISQ *s = init();
    printf("%d,%d", rear(s), outqueue(s));
    return 0;
}
